#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ----------------------------------------------------------
# -- 文件工具
# --
# ****************************
# Author: lmay.Zhou
# Blog: www.lmaye.com
# Date: 2021/9/22 15:06
# Email lmay@lmaye.com
# ----------------------------------------------------------
import os


def write_file(filename, content, out_path=None):
    """
        文件写入

        :param filename: 文件名称
        :param content: 文件内容
        :param out_path: 输出路径
        :return:
    """
    # 目录是否存在
    if out_path and not os.path.exists(out_path):
        os.makedirs(out_path)
    filename = out_path + os.path.sep + filename if out_path else filename
    with open(filename, 'w+', encoding='UTF-8', newline="\n") as file:
        file.write(content)
    file.close()


def remove_file(file_path):
    """
        文件删除

        :param file_path: 文件路径
    """
    os.remove(file_path)
